﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Dom1
{
    public partial class Uplode : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string filename = FileUpload1.FileName;
                string filefix = filename.Substring(filename.LastIndexOf('.')+1).ToLower();
                if (filefix=="jpg"||filefix=="png"||filefix=="pic"||filefix=="jpeg")
                {
                    FileUpload1.SaveAs(Server.MapPath(".")+"//img//"+filename);
                    this.Label1.Text = "上传成功";
                    this.Image1.ImageUrl = "/img/" + filename;
                }
                else
                {
                    this.Label1.Text = "选择的不是图片文件";
                }
            }
            else
            {
                this.Label1.Text = "上传失败";
            }
        }
    }
}